package com.seecen.controller;

import com.seecen.pojo.Favorites;
import com.seecen.service.*;
import com.seecen.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/favorite")
@CrossOrigin
public class FavoriteController {

    @Autowired
    private FavoritesService favoritesService;

    @Autowired
    private RecipesService recipesService;

    @Autowired
    private RecommendRecipesService recommendRecipesService;

    @Autowired
    private CuisineCategoriesService cuisineCategoriesService;

    @Autowired
    private UserService userService;

    @Autowired
    private FavoritesVideosService favoritesVideosService;

    @PostMapping("getFavoriteById")
    public Result getFavoriteById(@RequestParam("favoriteId") Integer favoriteId){
        Result ret = favoritesService.getFavoriteById(favoriteId);
        return ret;
    }

    @PostMapping("getFavoriteAll")
    public Result getFavoriteAll(){
        Result ret = favoritesService.getFavoriteAll();
        return ret;
    }

    @PostMapping("getRecommendRecipeAll")
    public Result getRecommendRecipeAll(){
        Result ret = recommendRecipesService.getRecommendRecipeAll();
        return ret;
    }

    @PostMapping("getCuisineCategoriesAll")
    public Result getCuisineCategoriesAll(){
        Result ret = cuisineCategoriesService.getCuisineCategoriesAll();
        return ret;
    }

    @PostMapping("getRecipesAll")
    public Result getRecipesAll(){
        Result ret = recipesService.getRecipesAll();
        return ret;
    }

    @PostMapping("getUserAll")
    public Result getUserAll(){
        Result ret = userService.getUserAll();
        return ret;
    }

    @PostMapping("getFavoriteVideosAll")
    public Result getFavoriteVideosAll(){
        Result ret = favoritesVideosService.getFavoriteVideosAll();
        return ret;
    }

    @PostMapping("insertFavoriteAll")
    public Result insertFavoriteAll(@RequestBody Favorites favorites){
        Result ret=favoritesService.insertFavoriteAll(favorites);
        return ret;
    }
    @PostMapping("deleteFavorite")
    public Result deleteFavorite(
            @RequestParam("recipeId") Integer recipeId) {
        Result ret = favoritesService.deleteFavorite(recipeId);
        return ret;
    }

    @GetMapping("selectFavoriteByUserId")
    public Result selectFavoriteByUserId(@RequestParam Integer userId){
        Result ret=favoritesService.selectFavoriteByUserId(userId);
        return ret;
    }

}
